/**
 * Copyright (c) 2020 kedacom
 * OpenATC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 **/
package com.openatc.agent.model;

import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
import lombok.Data;
import org.hibernate.annotations.*;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

@Data
@Entity
@Table(name = "sys_permission",schema = "auth2")
@TypeDef(name = "JsonbType", typeClass = JsonBinaryType.class)
public class Permission {

    @Id
    @GeneratedValue(generator = "sequence-generator_p")
    @GenericGenerator(
            name = "sequence-generator_p",
            strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
            parameters = {
                    @org.hibernate.annotations.Parameter(name = "sequence_name", value = "auth2.sys_permission_id_seq"),
                    @org.hibernate.annotations.Parameter(name = "initial_value", value = "1500"),
                    @Parameter(name = "increment_size", value = "1")
            }
    )
    private int id;

    @Column
    private String permission_code;

    @Column
    private String description;

    @Column(nullable = false)
    private short status;

    @Type(type = "JsonbType")
    @Column(columnDefinition = "jsonb",nullable = false)
    private String ext_infos = "{}";

    @Temporal(TemporalType.TIMESTAMP)
    @CreationTimestamp
    @Column(nullable = false,updatable = false)
    private Date create_time;

    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false)
    private Date update_time;

}